import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { UploadTypeEnum } from '/@/components/Form/src/jeecg/components/JUpload';

import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
import {FormActionType} from "@/components/Form";
//列表数据
export const columns: BasicColumn[] = [

   {
    title: '文件路径',
    align: 'center',
    dataIndex: 'filePath',
   },
   {
    title: '排序',
    align: 'left',
    dataIndex: 'fileOrder'
  },
  {
    title: '文件标签',
    align: 'center',
    dataIndex: 'fileLabel_dictText',
  },
   {
    title: '文件类型',
    align: 'center',
    dataIndex: 'fileType_dictText'
   },
   {
    title: '文件大小',
    align: 'center',
    dataIndex: 'fileSize'
   },
  {
    title: '文件名',
    align: 'left',
    dataIndex: 'fileName'
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "文件名",
      field: "fileName",
      component: 'Input',
      //colProps: {span: 6},
     },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '父级节点',
    field: 'parent',
    component: 'JTreeSelect',
    componentProps: {
      dict: "f_file_reord,file_name,id",
      pidField: "parent",
      pidValue: "0",
      hasChildField: "has_child",

    },
  },
  {
    label: '文件路径',
    field: 'filePath',
    component: 'JUpload',
    componentProps:({formActionType})=>{
      return{
        maxCount:1,
        fileType:UploadTypeEnum.file,
        returnUrl:false,
        onChange:(res)=>{
          let t = JSON.parse(res)
          console.log(t[0].fileName)

          formActionType.setFieldsValue({
            fileName:t[0].fileName,
            fileSize:t[0].fileSize,
            filePath:t[0].filePath,
            fileType:'2'
          })
        }
      }

    },
  },
  {
    label: '文件名',
    field: 'fileName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入文件名!'},
          ];
     },
  },
  {
    label: '文件标签',
    field: 'fileLabel',
    component: 'JSelectMultiple',
    componentProps:{
      dictCode:"file_label"
    },
    dynamicRules: ({model,schema}) => {
      return [
        { required: false, message: '请输入文件标签!'},
      ];
    },
  },
  {
    label: '文件类型',
    field: 'fileType',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"file_type"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入文件类型!'},
          ];
     },
  },
  {
    label: '排序',
    field: 'fileOrder',
    component: 'InputNumber',
    defaultValue:1,
    dynamicRules: ({model,schema}) => {
      return [
        { required: false, message: '请输入排序!'},
      ];
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
  {
    label: '',
    field: 'fileSize',
    component: 'Input',
    show: false
  }

];

// 高级查询数据
export const superQuerySchema = {
  fileName: {title: '文件名',order: 1,view: 'text', type: 'string',},
  filePath: {title: '文件路径',order: 2,view: 'file', type: 'string',},
  fileType: {title: '文件类型',order: 3,view: 'list', type: 'string',dictCode: 'file_type',},
  fileSize: {title: '文件大小',order: 4,view: 'number', type: 'number',},
};


/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
